package com.check.operation.service;

import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.check.operation.R;

/**
 * 病理标本条目
 * @author Administrator
 *
 */
public class CheckAdapter extends BaseAdapter {

	private LayoutInflater inflater;
	private List<String> data;
	
	public CheckAdapter(LayoutInflater inflater) {
		super();
		this.inflater = inflater;
	}

	public CheckAdapter(LayoutInflater inflater, List<String> data) {
		super();
		this.inflater = inflater;
		this.data = data;
	}

	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public String getItem(int position) {
		return data.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		String item = getItem(position);
		ViewHolder holder = null;
		if(view == null) {
			holder = new ViewHolder();
			view = inflater.inflate(R.layout.check_item, parent, false);

			holder.bb = (TextView) view.findViewById(R.id.bb);
			
			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}
		holder.bb.setText(item);
		return view;
	}

	static class ViewHolder {
		TextView bb;
	}
	
	public List<String> getData() {
		return data;
	}

	public void setData(List<String> data) {
		this.data = data;
	}

}
